# -*- coding: utf-8 -*-
# @Time     :2021/9/6 16:58
# @Author   : master
# @Software : PyCharm


from Common.basepage import BasePage
from PageLocators.loginpage_locators import LoginPageLocator as loc


class LoginPage(BasePage):

    def __init__(self, driver):
        self.driver = driver             # 由用例决定driver

    def login(self, username, password):
        doc = '登录页面-登录功能'
        # self.is_invisibility(loc.name_text, timeout=10, doc=doc)
        self.send_keys(loc.name_text, username, doc=doc)
        self.send_keys(loc.pwd_text, password, doc=doc)
        self.click(loc.login_but, doc=doc)

    def forgetThePassword(self):
        '''忘记密码'''
        pass

    def get_toast_loginArea(self):
        '''获取错误提示信息 - 登录区域'''
        doc = '登录页面-获取登录区域的错误提示'
        return self.get_text(loc.errorMsg_from_loginArea, doc=doc)

    def get_errorMsg_from_pageCenter(self):
        '''获取错误toast'''
        return self.get_text(loc.errorToast)
